// Copyright (C) <2018> Zealcomm Inc.
//
// SPDX-License-Identifier: Apache-2.0
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <WebRTC/RTCMacros.h>
#import <IRTC/IRTCMediaFormat.h>
NS_ASSUME_NONNULL_BEGIN
@class RTCLegacyStatsReport;
@class IRTCConferenceSubscription;
@class IRTCConferenceSubscriptionUpdateOptions;
RTC_EXPORT
@protocol IRTCConferenceSubscriptionDelegate <NSObject>
@optional
/// Subscription is ended.<br>订阅停止。
- (void)subscriptionDidEnd:(IRTCConferenceSubscription*)subscription;
/// Publication is muted. Remote side stopped sending audio and/or video data.<br>发布静默。远端停止发送音频或者视频数据。
- (void)subscriptionDidMute:(IRTCConferenceSubscription*)subscription
                  trackKind:(IRTCTrackKind)kind;
/// Publication is unmuted. Remote side continued sending audio and/or video data.<br>取消发布静默。远端继续发送音频或者视频数据。
- (void)subscriptionDidUnmute:(IRTCConferenceSubscription*)subscription
                    trackKind:(IRTCTrackKind)kind;
@end
RTC_EXPORT
@interface IRTCConferenceSubscription : NSObject
- (instancetype)init NS_UNAVAILABLE;
/// Stop certain subscription. Once a subscription is stopped, it cannot be recovered.<br>停止某个订阅。一旦订阅被停止，就不能恢复。
- (void)stop;
/// Stop reeving data from remote endpoint.<br>停止从远端接收媒体流数据。
- (void)mute:(IRTCTrackKind)trackKind
    onSuccess:(nullable void (^)())onSuccess
    onFailure:(nullable void (^)(NSError*))onFailure;
/// Continue reeving data from remote endpoint.<br>继续从远端接收媒体流数据。
- (void)unmute:(IRTCTrackKind)trackKind
     onSuccess:(nullable void (^)())onSuccess
     onFailure:(nullable void (^)(NSError*))onFailure;
/// Get stats of underlying PeerConnection.<br>获取当前PeerConnection的参数。
- (void)statsWithOnSuccess:(void (^)(NSArray<RTCLegacyStatsReport*>*))onSuccess
                 onFailure:(nullable void (^)(NSError*))onFailure;
/// Update subscription with given options.<br>用指定参数更新订阅。
- (void)applyOptions:(IRTCConferenceSubscriptionUpdateOptions*)options
           onSuccess:(nullable void (^)())onSuccess
           onFailure:(nullable void (^)(NSError*))onFailure;
@property(nonatomic, strong, readonly) NSString* subscriptionId;
@property(nonatomic, weak) id<IRTCConferenceSubscriptionDelegate> delegate;
@end

RTC_EXPORT
/// Constraints for subscribing a remote stream.<br>订阅远端媒体流的音频配置。
@interface IRTCConferenceAudioSubscriptionConstraints : NSObject
@property(nonatomic, assign) BOOL disabled;
@property(nonatomic, strong) NSArray<IRTCAudioCodecParameters*>* codecs;
@end
RTC_EXPORT
/// Constraints for subscribing a remote stream.<br>订阅远端媒体流的视频配置。
@interface IRTCConferenceVideoSubscriptionConstraints : NSObject
@property(nonatomic, assign) BOOL disabled;
@property(nonatomic, assign) CGSize resolution;
@property(nonatomic, assign) double frameRate;
@property(nonatomic, assign) double bitrateMultiplier;
@property(nonatomic, assign) NSUInteger keyFrameInterval;
@property(nonatomic, strong) NSArray<IRTCVideoCodecParameters*>* codecs;
@end
RTC_EXPORT
@interface IRTCConferenceSubscribeOptions : NSObject
- (instancetype)initWithAudio:(IRTCConferenceAudioSubscriptionConstraints*)audio
                        video:(IRTCConferenceVideoSubscriptionConstraints*)video;
@property(nonatomic, strong) IRTCConferenceAudioSubscriptionConstraints* audio;
@property(nonatomic, strong) IRTCConferenceVideoSubscriptionConstraints* video;
@end
RTC_EXPORT
/// Constraints for updating a subscription.<br>订阅更新参数。
@interface IRTCConferenceVideoSubscriptionUpdateConstraints : NSObject
@property(nonatomic, assign) CGSize resolution;
@property(nonatomic, assign) double frameRate;
@property(nonatomic, assign) double bitrateMultiplier;
@property(nonatomic, assign) NSUInteger keyFrameInterval;
@end
RTC_EXPORT
@interface IRTCConferenceSubscriptionUpdateOptions : NSObject
@property(nonatomic, strong)
    IRTCConferenceVideoSubscriptionUpdateConstraints* video;
@end
NS_ASSUME_NONNULL_END
